g_param_spec_int ("strength",
P_("Strength"),
P_("The strength of the constraint"),
- GTK_CONSTRAINT_STRENGTH_WEAK, G_MAXINT,
+ 0, GTK_CONSTRAINT_STRENGTH_REQUIRED,
GTK_CONSTRAINT_STRENGTH_REQUIRED,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS |
return constraint->strength;
}
-/*< private >
- * gtk_constraint_get_weight:
- * @constraint: a #GtkConstraint
- *
- * Computes the weight of the @constraint to be used with
- * #GtkConstraintSolver.
- *
- * Returns: the weight of the constraint
- */
-double
-gtk_constraint_get_weight (GtkConstraint *constraint)
-{
- if (constraint->strength > 0)
- return constraint->strength;
-
- switch (constraint->strength)
- {
- case GTK_CONSTRAINT_STRENGTH_REQUIRED:
- return GTK_CONSTRAINT_WEIGHT_REQUIRED;
-
- case GTK_CONSTRAINT_STRENGTH_STRONG:
- return GTK_CONSTRAINT_WEIGHT_STRONG;
-
- case GTK_CONSTRAINT_STRENGTH_MEDIUM:
- return GTK_CONSTRAINT_WEIGHT_MEDIUM;
-
- case GTK_CONSTRAINT_STRENGTH_WEAK:
- return GTK_CONSTRAINT_WEIGHT_WEAK;
-
- default:
- g_assert_not_reached ();
- }
-
- return 0;
-}
-
/**
* gtk_constraint_is_required:
* @constraint: a #GtkConstraint
var,
GTK_CONSTRAINT_RELATION_GE,
gtk_constraint_expression_new (guide->values[index]),
- GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
}
else if ((index == NAT_WIDTH && guide->values[MIN_WIDTH] != guide->values[MAX_WIDTH]) ||
(index == NAT_HEIGHT && guide->values[MIN_HEIGHT] != guide->values[MAX_HEIGHT]))
var,
GTK_CONSTRAINT_RELATION_LE,
gtk_constraint_expression_new (guide->values[index]),
- GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
}
gtk_layout_manager_layout_changed (GTK_LAYOUT_MANAGER (guide->layout));
gtk_constraint_solver_add_constraint (solver,
res, GTK_CONSTRAINT_RELATION_EQ, expr,
- GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
}
break;
gtk_constraint_solver_add_constraint (solver,
res, GTK_CONSTRAINT_RELATION_EQ, expr,
- GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
}
break;
gtk_constraint_solver_add_constraint (solver,
res, GTK_CONSTRAINT_RELATION_EQ, expr,
- GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
}
break;
gtk_constraint_solver_add_constraint (solver,
res, GTK_CONSTRAINT_RELATION_EQ, expr,
- GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
}
break;
expr = gtk_constraint_expression_new (0.0);
gtk_constraint_solver_add_constraint (solver,
res, GTK_CONSTRAINT_RELATION_GE, expr,
- GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
}
break;
gtk_constraint_solver_add_constraint (self->solver,
res, GTK_CONSTRAINT_RELATION_EQ, expr,
- GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
}
break;
gtk_constraint_solver_add_constraint (self->solver,
res, GTK_CONSTRAINT_RELATION_EQ, expr,
- GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
}
break;
gtk_constraint_solver_add_constraint (self->solver,
res, GTK_CONSTRAINT_RELATION_EQ, expr,
- GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
}
break;
gtk_constraint_solver_add_constraint (self->solver,
res, GTK_CONSTRAINT_RELATION_EQ, expr,
- GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
}
break;
expr = gtk_constraint_expression_new (0.0);
gtk_constraint_solver_add_constraint (self->solver,
res, GTK_CONSTRAINT_RELATION_GE, expr,
- GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
}
break;
target_attr,
gtk_constraint_get_relation (constraint),
expr,
- gtk_constraint_get_weight (constraint));
+ gtk_constraint_get_strength (constraint));
}
static void
child_info->constraints[index] =
gtk_constraint_solver_add_stay_variable (self->solver,
var,
- GTK_CONSTRAINT_WEIGHT_MEDIUM);
+ GTK_CONSTRAINT_STRENGTH_MEDIUM);
}
else
{
var,
relation[index],
gtk_constraint_expression_new (value),
- GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
}
}
}
* natural state of the system. Once we get the value out, we can
* remove these constraints
*/
- gtk_constraint_solver_add_edit_variable (solver, size, GTK_CONSTRAINT_WEIGHT_STRONG * 2);
+ gtk_constraint_solver_add_edit_variable (solver, size, GTK_CONSTRAINT_STRENGTH_STRONG * 2);
if (for_size > 0)
- gtk_constraint_solver_add_edit_variable (solver, opposite_size, GTK_CONSTRAINT_WEIGHT_STRONG * 2);
+ gtk_constraint_solver_add_edit_variable (solver, opposite_size, GTK_CONSTRAINT_STRENGTH_STRONG * 2);
gtk_constraint_solver_begin_edit (solver);
gtk_constraint_solver_suggest_value (solver, size, 0.0);
if (for_size > 0)
gtk_constraint_variable_set_value (layout_top, 0.0);
stay_t = gtk_constraint_solver_add_stay_variable (solver,
layout_top,
- GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
gtk_constraint_variable_set_value (layout_left, 0.0);
stay_l = gtk_constraint_solver_add_stay_variable (solver,
layout_left,
- GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
gtk_constraint_variable_set_value (layout_width, width);
stay_w = gtk_constraint_solver_add_stay_variable (solver,
layout_width,
- GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
gtk_constraint_variable_set_value (layout_height, height);
stay_h = gtk_constraint_solver_add_stay_variable (solver,
layout_height,
- GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
GTK_NOTE (LAYOUT,
g_print ("Layout [%p]: { .x: %g, .y: %g, .w: %g, .h: %g }\n",
self,
guint active : 1;
};
-double gtk_constraint_get_weight (GtkConstraint *constraint);
-
void gtk_constraint_attach (GtkConstraint *constraint,
GtkConstraintSolver *solver,
GtkConstraintRef *ref);
* e = gtk_constraint_expression_builder_finish (&builder);
* gtk_constraint_solver_add_constraint (solver,
* right, GTK_CONSTRAINT_RELATION_EQ, e,
- * GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ * GTK_CONSTRAINT_STRENGTH_REQUIRED);
*
* // right ≤ 100
* gtk_constraint_expression_builder_constant (&builder, 100.0);
* e = gtk_constraint_expression_builder_finish (&builder);
* gtk_constraint_solver_add_constraint (solver,
* right, GTK_CONSTRAINT_RELATION_LE, e,
- * GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ * GTK_CONSTRAINT_STRENGTH_REQUIRED);
*
* // middle = (left + right) / 2
* gtk_constraint_expression_builder_term (&builder, left);
* e = gtk_constraint_expression_builder_finish (&builder);
* gtk_constraint_solver_add_constraint (solver
* middle, GTK_CONSTRAINT_RELATION_EQ, e,
- * GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ * GTK_CONSTRAINT_STRENGTH_REQUIRED);
*
* // left ≥ 0
* gtk_constraint_expression_builder_constant (&builder, 0.0);
* e = gtk_constraint_expression_builder_finish (&builder);
* gtk_constraint_solver_add_constraint (solver,
* left, GTK_CONSTRAINT_RELATION_GE, e,
- * GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ * GTK_CONSTRAINT_STRENGTH_REQUIRED);
* ]|
*
* Now that we have all our constraints in place, suppose we wish to find
* |[
* // Set the value first
* gtk_constraint_variable_set_value (middle, 45.0);
- * // and then add the stay constraint, with a weak weight
- * gtk_constraint_solver_add_stay_variable (solver, middle, GTK_CONSTRAINT_WEIGHT_WEAK);
+ * // and then add the stay constraint, with a weak strength
+ * gtk_constraint_solver_add_stay_variable (solver, middle, GTK_CONSTRAINT_STRENGTH_WEAK);
* ]|
*
* GtkConstraintSolver incrementally solves the system every time a constraint
/* The original relation used when creating the constraint */
GtkConstraintRelation relation;
- /* The weight, or strength, of the constraint */
- double weight;
+ /* The strength of the constraint; this value is used to strengthen
+ * or weaken a constraint weight in the tableau when coming to a
+ * solution
+ */
+ int strength;
GtkConstraintSolver *solver;
static gboolean
gtk_constraint_ref_is_required (const GtkConstraintRef *self)
{
- return self->weight >= GTK_CONSTRAINT_WEIGHT_REQUIRED;
+ return self->strength == GTK_CONSTRAINT_STRENGTH_REQUIRED;
}
static const char *relations[] = {
}
static const char *
-weight_to_string (double s)
+strength_to_string (int s)
{
- if (s >= GTK_CONSTRAINT_WEIGHT_REQUIRED)
- return "required";
-
- if (s >= GTK_CONSTRAINT_WEIGHT_STRONG)
+ if (s >= GTK_CONSTRAINT_STRENGTH_STRONG)
return "strong";
- if (s >= GTK_CONSTRAINT_WEIGHT_MEDIUM)
+ if (s >= GTK_CONSTRAINT_STRENGTH_MEDIUM)
return "medium";
return "weak";
g_string_append (buf, relation_to_string (self->relation));
g_string_append (buf, " 0.0");
- g_string_append_printf (buf, " [weight:%s (%g)]",
- weight_to_string (self->weight),
- self->weight);
+ if (gtk_constraint_ref_is_required (self))
+ g_string_append (buf, " [strength:required]");
+ else
+ g_string_append_printf (buf, " [strength:%d (%s)]",
+ self->strength,
+ strength_to_string (self->strength));
return g_string_free (buf, FALSE);
}
gtk_constraint_variable_unref (eminus);
z_row = g_hash_table_lookup (self->rows, self->objective);
- gtk_constraint_expression_set_variable (z_row, eminus, constraint->weight);
+ gtk_constraint_expression_set_variable (z_row, eminus, constraint->strength);
gtk_constraint_solver_insert_error_variable (self, constraint, eminus);
gtk_constraint_solver_note_added_variable (self, eminus, self->objective);
z_row = g_hash_table_lookup (self->rows, self->objective);
- gtk_constraint_expression_set_variable (z_row, eplus, constraint->weight);
- gtk_constraint_expression_set_variable (z_row, eminus, constraint->weight);
+ gtk_constraint_expression_set_variable (z_row, eplus, constraint->strength);
+ gtk_constraint_expression_set_variable (z_row, eminus, constraint->strength);
gtk_constraint_solver_note_added_variable (self, eplus, self->objective);
gtk_constraint_solver_note_added_variable (self, eminus, self->objective);
* @variable: the subject of the constraint
* @relation: the relation of the constraint
* @expression: the expression of the constraint
- * @strength: the weight of the constraint
+ * @strength: the strength of the constraint
*
* Adds a new constraint in the form of:
*
GtkConstraintVariable *variable,
GtkConstraintRelation relation,
GtkConstraintExpression *expression,
- double strength)
+ int strength)
{
GtkConstraintRef *res = g_new0 (GtkConstraintRef, 1);
res->solver = self;
- res->weight = strength;
+ res->strength = strength;
res->is_edit = FALSE;
res->is_stay = FALSE;
res->relation = relation;
* gtk_constraint_solver_add_stay_variable:
* @self: a #GtkConstraintSolver
* @variable: a stay #GtkConstraintVariable
- * @strength: the weight of the constraint
+ * @strength: the strength of the constraint
*
* Adds a constraint on a stay @variable with the given @strength.
*
GtkConstraintRef *
gtk_constraint_solver_add_stay_variable (GtkConstraintSolver *self,
GtkConstraintVariable *variable,
- double strength)
+ int strength)
{
GtkConstraintRef *res = g_new0 (GtkConstraintRef, 1);
res->solver = self;
res->variable = gtk_constraint_variable_ref (variable);
res->relation = GTK_CONSTRAINT_RELATION_EQ;
- res->weight = strength;
+ res->strength = strength;
res->is_stay = TRUE;
res->is_edit = FALSE;
GtkConstraintRef *
gtk_constraint_solver_add_edit_variable (GtkConstraintSolver *self,
GtkConstraintVariable *variable,
- double strength)
+ int strength)
{
GtkConstraintRef *res = g_new0 (GtkConstraintRef, 1);
res->solver = self;
res->variable = gtk_constraint_variable_ref (variable);
res->relation = GTK_CONSTRAINT_RELATION_EQ;
- res->weight = strength;
+ res->strength = strength;
res->is_stay = FALSE;
res->is_edit = TRUE;
{
gtk_constraint_expression_add_variable (z_row,
v,
- constraint->weight,
+ constraint->strength,
self->objective,
self);
}
{
gtk_constraint_expression_add_expression (z_row,
e,
- constraint->weight,
+ constraint->strength,
self->objective,
self);
}
G_DECLARE_FINAL_TYPE (GtkConstraintSolver, gtk_constraint_solver, GTK, CONSTRAINT_SOLVER, GObject)
-/* Symbolic weight thresholds
- *
- * Constraint weights live on a continuum, but we use thresholds for simplicity's
- * sake, so we don't have to necessarily reason in terms of numeric values.
- *
- * The public API has a similar approach, where the symbolic constants are negative
- * values, and positive values are explicit weights. We map those values into
- * numeric values that the GtkConstraintSolver can plug into the linear equations
- * tableau.
- */
-#define GTK_CONSTRAINT_WEIGHT_REQUIRED (make_weight (1000, 1000, 1000, 1))
-#define GTK_CONSTRAINT_WEIGHT_STRONG (make_weight ( 1, 0, 0, 1))
-#define GTK_CONSTRAINT_WEIGHT_MEDIUM (make_weight ( 0, 1, 0, 1))
-#define GTK_CONSTRAINT_WEIGHT_WEAK (make_weight ( 0, 0, 1, 1))
-
-G_GNUC_PURE
-static inline double
-make_weight (double a,
- double b,
- double c,
- double w)
-{
- double res = 0;
-
- res += CLAMP (a * w, 0, 1000) * 1000000;
- res += CLAMP (b * w, 0, 1000) * 1000;
- res += CLAMP (c * w, 0, 1000);
-
- return res;
-}
-
GtkConstraintSolver *
gtk_constraint_solver_new (void);
GtkConstraintVariable *variable,
GtkConstraintRelation relation,
GtkConstraintExpression *expression,
- double strength);
+ int strength);
void
gtk_constraint_solver_remove_constraint (GtkConstraintSolver *solver,
GtkConstraintRef *
gtk_constraint_solver_add_stay_variable (GtkConstraintSolver *solver,
GtkConstraintVariable *variable,
- double strength);
+ int strength);
void
gtk_constraint_solver_remove_stay_variable (GtkConstraintSolver *solver,
GtkConstraintRef *
gtk_constraint_solver_add_edit_variable (GtkConstraintSolver *solver,
GtkConstraintVariable *variable,
- double strength);
+ int strength);
void
gtk_constraint_solver_remove_edit_variable (GtkConstraintSolver *solver,
* integer; the values of this enumeration can be used for readability.
*/
typedef enum {
- GTK_CONSTRAINT_STRENGTH_REQUIRED = 0,
- GTK_CONSTRAINT_STRENGTH_STRONG = -1,
- GTK_CONSTRAINT_STRENGTH_MEDIUM = -2,
- GTK_CONSTRAINT_STRENGTH_WEAK = -3
+ GTK_CONSTRAINT_STRENGTH_REQUIRED = 1001001000,
+ GTK_CONSTRAINT_STRENGTH_STRONG = 1000000000,
+ GTK_CONSTRAINT_STRENGTH_MEDIUM = 1000,
+ GTK_CONSTRAINT_STRENGTH_WEAK = 1
} GtkConstraintStrength;
/**
gtk_constraint_solver_add_constraint (solver,
x, GTK_CONSTRAINT_RELATION_EQ, e,
- GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
double x_value = gtk_constraint_variable_get_value (x);
double y_value = gtk_constraint_variable_get_value (y);
GtkConstraintVariable *x = gtk_constraint_solver_create_variable (solver, NULL, "x", 5.0);
GtkConstraintVariable *y = gtk_constraint_solver_create_variable (solver, NULL, "y", 10.0);
- gtk_constraint_solver_add_stay_variable (solver, x, GTK_CONSTRAINT_WEIGHT_WEAK);
- gtk_constraint_solver_add_stay_variable (solver, y, GTK_CONSTRAINT_WEIGHT_WEAK);
+ gtk_constraint_solver_add_stay_variable (solver, x, GTK_CONSTRAINT_STRENGTH_WEAK);
+ gtk_constraint_solver_add_stay_variable (solver, y, GTK_CONSTRAINT_STRENGTH_WEAK);
double x_value = gtk_constraint_variable_get_value (x);
double y_value = gtk_constraint_variable_get_value (y);
gtk_constraint_solver_add_constraint (solver,
x, GTK_CONSTRAINT_RELATION_GE, e,
- GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
double x_value = gtk_constraint_variable_get_value (x);
gtk_constraint_solver_add_constraint (solver,
x, GTK_CONSTRAINT_RELATION_LE, e,
- GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
double x_value = gtk_constraint_variable_get_value (x);
gtk_constraint_solver_add_constraint (solver,
x, GTK_CONSTRAINT_RELATION_EQ, e,
- GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
double x_value = gtk_constraint_variable_get_value (x);
gtk_constraint_expression_builder_term (&builder, width);
GtkConstraintExpression *right = gtk_constraint_expression_builder_finish (&builder);
- gtk_constraint_solver_add_stay_variable (solver, width, GTK_CONSTRAINT_WEIGHT_WEAK);
- gtk_constraint_solver_add_stay_variable (solver, right_min, GTK_CONSTRAINT_WEIGHT_WEAK);
+ gtk_constraint_solver_add_stay_variable (solver, width, GTK_CONSTRAINT_STRENGTH_WEAK);
+ gtk_constraint_solver_add_stay_variable (solver, right_min, GTK_CONSTRAINT_STRENGTH_WEAK);
gtk_constraint_solver_add_constraint (solver,
right_min, GTK_CONSTRAINT_RELATION_EQ, right,
- GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
double x_value = gtk_constraint_variable_get_value (x);
double width_value = gtk_constraint_variable_get_value (width);
e = gtk_constraint_expression_new_from_variable (y);
gtk_constraint_solver_add_constraint (solver,
x, GTK_CONSTRAINT_RELATION_LE, e,
- GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
e = gtk_constraint_expression_plus_constant (gtk_constraint_expression_new_from_variable (x), 3.0);
gtk_constraint_solver_add_constraint (solver,
y, GTK_CONSTRAINT_RELATION_EQ, e,
- GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
e = gtk_constraint_expression_new (10.0);
gtk_constraint_solver_add_constraint (solver,
x, GTK_CONSTRAINT_RELATION_EQ, e,
- GTK_CONSTRAINT_WEIGHT_WEAK);
+ GTK_CONSTRAINT_STRENGTH_WEAK);
e = gtk_constraint_expression_new (10.0);
gtk_constraint_solver_add_constraint (solver,
y, GTK_CONSTRAINT_RELATION_EQ, e,
- GTK_CONSTRAINT_WEIGHT_WEAK);
+ GTK_CONSTRAINT_STRENGTH_WEAK);
double x_val = gtk_constraint_variable_get_value (x);
double y_val = gtk_constraint_variable_get_value (y);
GtkConstraintSolver *solver = gtk_constraint_solver_new ();
GtkConstraintVariable *a = gtk_constraint_solver_create_variable (solver, NULL, "a", 0.0);
- gtk_constraint_solver_add_stay_variable (solver, a, GTK_CONSTRAINT_WEIGHT_STRONG);
+ gtk_constraint_solver_add_stay_variable (solver, a, GTK_CONSTRAINT_STRENGTH_STRONG);
g_assert_cmpfloat_with_epsilon (gtk_constraint_variable_get_value (a), 0.0, 0.001);
- gtk_constraint_solver_add_edit_variable (solver, a, GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ gtk_constraint_solver_add_edit_variable (solver, a, GTK_CONSTRAINT_STRENGTH_REQUIRED);
gtk_constraint_solver_begin_edit (solver);
gtk_constraint_solver_suggest_value (solver, a, 2.0);
gtk_constraint_solver_resolve (solver);
GtkConstraintVariable *a = gtk_constraint_solver_create_variable (solver, NULL, "a", 0.0);
GtkConstraintVariable *b = gtk_constraint_solver_create_variable (solver, NULL, "b", 0.0);
- gtk_constraint_solver_add_stay_variable (solver, a, GTK_CONSTRAINT_WEIGHT_STRONG);
+ gtk_constraint_solver_add_stay_variable (solver, a, GTK_CONSTRAINT_STRENGTH_STRONG);
GtkConstraintExpression *e = gtk_constraint_expression_new_from_variable (b);
gtk_constraint_solver_add_constraint (solver,
a, GTK_CONSTRAINT_RELATION_EQ, e,
- GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
gtk_constraint_solver_resolve (solver);
g_assert_cmpfloat_with_epsilon (gtk_constraint_variable_get_value (a), 0.0, 0.001);
g_assert_cmpfloat_with_epsilon (gtk_constraint_variable_get_value (b), 0.0, 0.001);
- gtk_constraint_solver_add_edit_variable (solver, a, GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ gtk_constraint_solver_add_edit_variable (solver, a, GTK_CONSTRAINT_STRENGTH_REQUIRED);
gtk_constraint_solver_begin_edit (solver);
gtk_constraint_solver_suggest_value (solver, a, 2.0);
expr = gtk_constraint_expression_builder_finish (&builder);
gtk_constraint_solver_add_constraint (solver,
middle, GTK_CONSTRAINT_RELATION_EQ, expr,
- GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
gtk_constraint_expression_builder_init (&builder, solver);
gtk_constraint_expression_builder_term (&builder, left);
expr = gtk_constraint_expression_builder_finish (&builder);
gtk_constraint_solver_add_constraint (solver,
right, GTK_CONSTRAINT_RELATION_EQ, expr,
- GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
expr = gtk_constraint_expression_new (100.0);
gtk_constraint_solver_add_constraint (solver,
right, GTK_CONSTRAINT_RELATION_LE, expr,
- GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
expr = gtk_constraint_expression_new (0.0);
gtk_constraint_solver_add_constraint (solver,
left, GTK_CONSTRAINT_RELATION_GE, expr,
- GTK_CONSTRAINT_WEIGHT_REQUIRED);
+ GTK_CONSTRAINT_STRENGTH_REQUIRED);
g_test_message ("Check constraints hold");
g_assert_cmpfloat (gtk_constraint_variable_get_value (left), >=, 0.0);
gtk_constraint_variable_set_value (middle, 45.0);
- gtk_constraint_solver_add_stay_variable (solver, middle, GTK_CONSTRAINT_WEIGHT_WEAK);
+ gtk_constraint_solver_add_stay_variable (solver, middle, GTK_CONSTRAINT_STRENGTH_WEAK);
g_test_message ("Check constraints hold after setting middle");